package com.lcw.lostandfound.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lcw.lostandfound.mapper.NoticeMapper;
import com.lcw.lostandfound.pojo.Notice;
import com.lcw.lostandfound.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NoticeServiceImpl implements NoticeService {
    @Autowired
    private NoticeMapper noticeMapper;
    @Override
    public List<Notice> findAllNotice() {
        return noticeMapper.findAllNotice();
    }

    @Override
    public int deleteNotice(Integer id) {
        return noticeMapper.deleteNotice(id);
    }

    @Override
    public int updateNotice(Notice notice) {
        return noticeMapper.updateNotice(notice);
    }

    @Override
    public int insertNotice(Notice notice) {
        return noticeMapper.insertNotice(notice);
    }

    @Override
    public Notice queryNoticeById(Integer id) {
        return noticeMapper.queryNotice(id);
    }

    @Override
    public PageInfo<Notice> listNotices(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Notice> allNotice = noticeMapper.findAllNotice();
        return new PageInfo<>(allNotice);
    }
}
